#coding=utf-8

import sys
from pyquery import PyQuery as pq
from lxml import etree
# d = pq(url='http://m.weather.com.cn/mweather15d/101220101.shtml', parser='html')
ct_dct={
'合肥':'101220101',
'庐江':'101220106',
'肥西':'101220104',
'巢湖':'101220105'
}
if len(sys.argv) < 2 or len(sys.argv[1]) == 0:
	print """%s
python me.py 庐江
""" % (','.join( ct_dct.keys() ) )
	exit(1)

cityname=sys.argv[1]

citycode=ct_dct[cityname]
# print citycode 
d = pq(url='http://m.weather.com.cn/mweather15d/%s.shtml' % (citycode), parser='html')

ls=[
	u'%s：   白天：  %s；     夜晚： %s' % (
	d('#layout > div.yb15 > table:nth-child(%s) > tr:nth-child(1) > th > span:nth-child(2)' % (i) ).text() , 
	d('#layout > div.yb15 > table:nth-child(%s) > tr:nth-child(3) > td:nth-child(1)' % (i) ).text() ,
	d('#layout > div.yb15 > table:nth-child(%s) > tr:nth-child(3) > td:nth-child(2)' % (i) ).text() 
	)
for i in range(2,17)
]

print d('head > title').text()
print '\r\n'.join(ls)

